/**
 * Sample React Native App
 * https://github.com/facebook/react-native
 * @flow
 */

import React, { Component } from 'react';
import {
  AppRegistry,
  StyleSheet,
  Text,
  View,
  TextInput,
  Button,
  Alert,
    TouchableOpacity,
ScrollView
} from 'react-native';

import JuNetResquest    from './JuNetResquest';
import MyTextInput      from './MyTextInput'
import MyCustomButton   from './MyCustomButton'
import tableView        from './tableView'
import FlexLayout       from './FlexLayout'
import Playground       from './Playground'
import MyComponent      from './ES6'
import MyFlatList       from './MyFlatList'
import ModalExample     from './Explorer/ModalExample'
// import FlatListExample from './NewFlatList'
import DatePickerExample from './MyDatePicker'
//导入原生UI
import MapView from './MapView'

//导入原生类
import { NativeModules } from 'react-native';
var CalendarManager = NativeModules.CalendarManager;
// CalendarManager.juEvent('Birthday Party', '4 Privet Drive, Surrey');

CalendarManager.findCall((error, events) => {
    if (error) {
        console.error(error);
    } else {
        console.log(events);
        // this.setState({events: events});
    }
})

CalendarManager.executeCommand({"jute":"123456"})
    .then(
        (result) => {
            console.log(result);
        })
    .catch(
        (error) => {

        });

// CalendarManager.alertUserPromise()
//     .then((datas)=> {
//         console.warn('data', datas);
//     })
//     .catch((err)=> {
//         console.warn('err', err);
//     });

const onButtonPress = () => {
    Alert.alert('Button has been pressed!');
};
class testOne extends Component {

    clickJump(){
        const{navigator} = this.props;
        if(navigator){

            navigator.push({　　//navigator.push 传入name和你想要跳的组件页面
                name: "AlignItemsBasics",
                component: AlignItemsBasics
            });

        }
        else {
            this._alertPromise();
            // Alert.alert("提示","没有导航栏");
        }
    }
    _onPressButton(e) {
        console.log(e);
    }
    render() {
        var resquest =new JuNetResquest();
        resquest.getDataFromFetchs();

        return (
            <View style={{top:64}}>
                <View style={{flexDirection: 'row',marginTop:30,marginLeft:15,height:40}}>
                    <Text style={{fontSize:16,width:65,lineHeight:40}}>手机号:</Text>
                    <TextInput style={{height: 40,width:200}} placeholder="输入手机号" onChangeText={(text) => this.setState({text})}></TextInput>
                </View>
                <View style={{flexDirection: 'row',marginLeft:15}}>
                    <Text style={{fontSize:16,width:65,lineHeight:40}}>密码:</Text>
                    <TextInput style={{height: 40,width:200}} placeholder="输入密码" onChangeText={(text) => this.setState({text})}></TextInput>
                </View>

                <Button
                    onPress={this.clickJump.bind(this)}
                    title="登录"
                    accessibilityLabel="See an informative alert"
                />
                <MapView pitchEnabled={false} style={{height:300}}/>
            </View>
        );
    }

    async  _alertPromise() {
        try {
            var datas = await CalendarManager.alertUserPromise();
            console.warn('data', datas);
        } catch (e) {
            console.warn('err', e);
        }
    }
}

AppRegistry.registerComponent('testOne', () => MyCustomButton);
